import cv2
import numpy as np

X_train=[]

data = cv2.imread('./cnndata/1.jpg',0)
data_1 = data.reshape(-1)
X_train.append(data_1)

data = cv2.imread('./cnndata/2.jpg',0)
data_1 = data.reshape(-1)
X_train.append(data_1)

data = cv2.imread('./cnndata/3.jpg',0)
data_1 = data.reshape(-1)
X_train.append(data_1)

print(X_train)
Y_train=[0,1,2]

id_name={'0':'甲虫','1':'蜻蜓','2':'蝉'}
print(Y_train)

from sklearn.preprocessing import StandardScaler
nn =StandardScaler()
X_train = nn.fit_transform(X_train)
# X_test =  nn.fit_transform(X_test)

from sklearn.neural_network import MLPClassifier
mlp = MLPClassifier(solver='lbfgs',hidden_layer_sizes=[10,10],activation='tanh',alpha=1)
mlp.fit(X_train,Y_train)

res = mlp.predict([X_train[2]])
print(res)
print(id_name[str(res[0])])


print('=======================================================\n')
# print('测试数据集得分：{0}'.format(mlp.score(X_test,Y_test)))
print('=======================================================\n')

#
# cv2.imshow('1',data)
# cv2.waitKey(1)


